package com.cloud.zuul.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.core.ResolvableType;
import org.springframework.stereotype.Component;

@Component("applicationEventMulticaster")
public class RefreshEventMulticaster extends SimpleApplicationEventMulticaster {

    @Autowired
    private ConfigLoader configLoader;

    @Override
    public void multicastEvent(final ApplicationEvent event, ResolvableType eventType) {
        if (event instanceof RefreshRemoteApplicationEvent) {
            configLoader.load();
            return;
        }
        super.multicastEvent(event, eventType);
    }

}
